$(document).ready(function() {
    showLoading();
    $('title', parent.document).html($('title').text());
    setBaseUrl();
    addTitle("userManageSave");
    createComBody("detailOneBody", userManageTable, undefined, 1);
    createComBody("detailTwoBody", userManageTable, undefined, 2, true);
    createComBody("detailThreeBody", userManageTable, undefined, 3, true);
    $ajaxList('role', getRoleID);
	$ajaxList('branchCompany', getBranchCompany);
	$ajaxList('chargingStation', getChargingStation);
	$("#onLine").hide();
	$("#loadTime").hide();
	$("#onloadEquipment").hide();
	setTimeout(hideLoading, 500);
});
function getRoleID(data) {
	var length = data.length;
	for (var i = 0; i < length; i++) {
		$("#roleID").append("<option value='" + data[i].roleID + "'>" + data[i].roleName + "</option>");
	}
}
function getBranchCompany(data) {
	var length = data.length;
	for (var i = 0; i < length; i++) {
		$("#branchCompanyID").append("<option value='" + data[i].branchCompanyID + "'>" + data[i].branchCompanyName + "</option>");
	}
}
function getChargingStation(data) {
	var length = data.length;
	for (var i = 0; i < length; i++) {
		$("#chargingStationID").append("<option value='" + data[i].chargingStationID + "'>" + data[i].chargingStationName + "</option>");
	}
}
function goback() {
	window.parent.skipMenu('userManage/userManage', 'drownDown5', '', 'userPage', 'userMangeLi');
}
function confirm(){
	if ($("#passwordMD5").val()) {
		$("#password").val($.md5($("#passwordMD5").val()));
	}
	return checkForm("saveForm", userManageTable);
}
function saveUser(data){
	var result = data && data.result;
	if (result == "Success") {
		showMessge(messageContent["Insert.Success"], undefined, goback);
	} else if (result == "NotFound") {
		showMessge(messageContent["Insert.Failed"]);
	} else {
		showMessge(messageContent["Insert.Error"]);
	}
}
